#include<iostream>
using namespace std;
const int N = 1e5 + 10;
int arr[N], q[N], f[N];
int n;
int main()
{
	while (cin >> arr[n]) {
		n++;
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		f[i] = 1;
		for (int j = 0; j < i; j++) {
			if (arr[j] > arr[i]) {
				f[i] = max(f[i], f[j] + 1);
			}
		}
		ans = max(f[i], ans);
	}
	cout << ans << endl;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int k = 0;
		while (k < cnt && q[k] < arr[i]) {
			k++;
		}
		q[k] = arr[i];
		if (k == cnt) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}